FROM maven:3.6.3-openjdk-8 as build
RUN sed -i '/<mirrors>/a\    <mirror>\n      <id>nexus-tencentyun</id>\n      <mirrorOf>*</mirrorOf>\n      <name>Nexus tencentyun</name>\n      <url>http://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url>\n    </mirror>' /usr/share/maven/conf/settings.xml
RUN git -C /usr/src clone https://gitee.com/setamv/keycloak-services-social-wechatwork.git && \
    cd /usr/src/keycloak-services-social-wechatwork && \
    mvn clean package

FROM quay.io/keycloak/keycloak:6.0.1
COPY --from=build /usr/src/keycloak-services-social-wechatwork/target/keycloak-services-social-wechat-work-6.0.1.jar /opt/jboss/keycloak/providers/keycloak-services-social-wechat-work-6.0.1.jar
COPY --from=build /usr/src/keycloak-services-social-wechatwork/themes/base/admin/resources/partials/realm-identity-provider-wechat-work.html /opt/jboss/keycloak/themes/base/admin/resources/partials/realm-identity-provider-wechat-work.html
COPY --from=build /usr/src/keycloak-services-social-wechatwork/themes/base/admin/resources/partials/realm-identity-provider-wechat-work-ext.html /opt/jboss/keycloak/themes/base/admin/resources/partials/realm-identity-provider-wechat-work-ext.html
RUN sed -i '/<dependencies>/a\        <module name="org.infinispan" services="import"\/>' /opt/jboss/keycloak/modules/system/layers/keycloak/org/keycloak/keycloak-services/main/module.xml


